package com.example.payFees.service.Impl;

import com.example.entity.PayFees;
import com.example.payFees.dao.PayFeesMapper;
import com.example.payFees.service.PayFeesService;
import com.example.result.CommonResult;
import com.example.utils.MyPageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class PayFeesServiceImpl implements PayFeesService {
    @Autowired
    PayFeesMapper payFeesMapper;
    /**
     * 停车场管理-缴费全查
     * @param payFeesStall
     * @return
     */
    @Override
    public CommonResult getPayFees(String payFeesStall) {
        return CommonResult.ok(MyPageHelper.getPageResult(payFeesMapper.getPayFees(payFeesStall)));
    }

    /**
     * 停车场管理-缴费删除
     * @param id
     * @return
     */
    @Override
    public int delPayFees(Integer id) {
        int i = payFeesMapper.delPayFees(id);
        return i;
    }

    /**
     * 停车场管理-增改缴费
     * @param payFees
     * @return
     */
    @Override
    public int saveOrUpdatePayFees(PayFees payFees) {
        int i = 0;
        if(payFees.getId() == 0){
            payFees.setCreateTime(new Date());
            payFees.setUpdateTime(new Date());
            payFees.setPayFeesDelFlag(0);
            i = payFeesMapper.addPayFees(payFees);
        }else {
            payFees.setUpdateTime(new Date());
            i = payFeesMapper.updatePayFees(payFees);
        }
        return i;
    }
}
